﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HCM_maps_website.Models;

namespace HCM_maps_website.Process.DAL
{
    public class ServiceTypeDAO
    {
        static MapDataDataContext context = new MapDataDataContext();

        public ServiceTypeDAO()
        {
        }

        public static ServiceType GetServiceTypeInfo(int serviceTypeId)
        {    
            ServiceType result = new ServiceType();

            var type = context.sp_PlaceType_GetPlaceTypeInfo(serviceTypeId);

            foreach (var t in type)
            {
                result.ID = t.id;
                result.Description = t.description;
                result.Picture = t.picture;
                break;
            }

            return result;
        }

        public IList<ServiceType> GetListServiceType()
        {
            IList<ServiceType> listType = new List<ServiceType>();

            var listTypeQuery = context.sp_PlaceType_GetListPlaceType();

            foreach (var t in listTypeQuery)
            {
                ServiceType temp = new ServiceType();
                temp.ID = t.ID;
                temp.Description = t.Description;
                temp.Picture = t.Picture;
                listType.Add(temp);
            }

            return listType;
        }
    }
}